﻿var upload = {};
upload.version = "v1";
upload.server = "http://192.168.0.40:8080/";

upload.api = {
    getToken: upload.server + "token/getToken", //POST:
    uploadImage: upload.server + "upload/image", //POST:{imageBase64:base64,fileName:文件名}
}

var uploadAjax = {
    getToken: function (methods) {
        Network.connect(upload.api.getToken, 'POST', {}, methods,false);
    },
    uploadImage: function (param, methods) {
        Network.connect(upload.api.uploadImage, 'POST', param, methods,false);
    },
    upload: function (param, methods) {
        uploadAjax.getToken(function (res) {
            if (res.code == ResponseCode.OK) {
                var token = res.data;
                var url = upload.api.uploadImage + "?token=" + token;
                Network.connect(url, 'POST', param, methods, false,false);
            }
            else {
                Tools.alert('获取上传Token失败。');
            }            
        });        
    },
}
